/**
 * @author 董一华
 * @since 1.00
 * @version 1.00
 * 
 * 返回/跳转URL页面按钮控件
 * 使用说明：
 * jsp中使用范例：<htdz-tag:ButtonReturnTag url=""/>
 * 
 * 参数说明：
 * 1. hide是否隐藏,可选值:true,false。缺省值为false
 * 2. url:必填项
 * 3. value:按钮名称，缺省值为"返 回"
 * 
 * 修订列表： v1.00 2011-08-26 
 * 			修订人：董一华 
 * 			修订内容：初始版本
 * 
 */

package com.zjht.gmcc.bean.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.zjht.gmcc.bean.util.MyFormat;

public class ButtonReturnTag extends TagSupport {
	private static final long serialVersionUID = 7343418033252888637L;
	private boolean hide;
	private String url;
	private String value;

	public ButtonReturnTag() {
	}

	@SuppressWarnings("static-access")
	public int doStartTag() throws JspException {
		boolean hide = this.hide;
		String url = this.url;
		String value = this.value;
		StringBuilder html = new StringBuilder();

		if (MyFormat.isStrNull(value)) {
			value = "返 回";
		}
		try {
			html.append("<input id=\"return__\" type=\"button\" ");
			if (!MyFormat.isStrNull(url)) {
				html.append(" onclick=\"javascript:showDiv();location.href='");
				html.append(url);
				html.append("';\" ");
			}
			html.append(MyFormat.getButtonClass(value));
			if (hide) {
				html.append(" style=\"display:none\"");
			}
			html.append(" />");
			pageContext.getOut().print(html.toString());
		} catch (Exception e) {
			throw new JspException(e.getMessage());
		}
		html = null;
		return this.SKIP_BODY;
	}

	public void setHide(boolean hide) {
		this.hide = hide;
	}

	public void setHide(String hide) {
		this.hide = (hide != null && "true".equals(hide.trim().toLowerCase()));
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public void setValue(String value) {
		this.value = value;
	}
}
